package com.faeple.common.dao.sqlmap;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.faeple.common.dao.CommonDao;
import com.faeple.common.entity.InquiryDto;
import com.faeple.common.entity.NoticeDto;
import com.faeple.post.entity.PostDto;
import com.faeple.user.entity.UserDto;

@Repository
public class SqlMapCommonDao implements CommonDao {
	
	@Autowired
	private SqlSession sqlSession;

	@Override
	public List<UserDto> getRecommendUser(String idx) {
		return sqlSession.selectList("CommonMapper.getRecommendUser", idx);
	}

	@Override
	public List<String> getUserLastPostImages(String idx) {
		return sqlSession.selectList("CommonMapper.getUserLastPostImages", idx);
	}

	@Override
	public int twitterMemberRegistCheck(Long id) {
		return sqlSession.selectOne("CommonMapper.twitterMemberRegistCheck", id);
	}

	@Override
	public int twitterMemberRegist(HashMap<String, Object> map) {
		return sqlSession.insert("CommonMapper.twitterMemberRegist", map);
	}

	@Override
	public UserDto twitterLogin(long idx) {
		return sqlSession.selectOne("CommonMapper.twitterLogin", idx);
	}

	@Override
	public List<PostDto> searchPost(HashMap<String, String> param) {
		return sqlSession.selectList("CommonMapper.searchPost", param);
	}

	@Override
	public List<UserDto> searchUser(HashMap<String, String> param) {
		return sqlSession.selectList("CommonMapper.searchUser", param);
	}

	@Override
	public int getSearchUserCount(String value) {
		return sqlSession.selectOne("CommonMapper.getSearchUserCount", value);
	}
	
	@Override
	public List<NoticeDto> getNoticeList() {
		return sqlSession.selectList("CommonMapper.getNoticeList");
	}

	@Override
	public int eventSubmit(HashMap<String, String> param) {
		return sqlSession.insert("CommonMapper.eventSubmit", param);
	}

	@Override
	public List<HashMap<String, String>> getEventList() {
		return sqlSession.selectList("CommonMapper.getEventList");
	}

	@Override
	public int inquiryWrite(HashMap<String, String> param) {
		return sqlSession.insert("CommonMapper.inquiryWrite", param);
	}

	@Override
	public List<InquiryDto> getMyInquiry(String idx) {
		return sqlSession.selectList("CommonMapper.getMyInquiry", idx);
	}

	@Override
	public int checkInstagramMemberRegist(String appIdx) {
		return sqlSession.selectOne("CommonMapper.checkInstagramMemberRegist", appIdx);
	}

	@Override
	public int instagramMemberRegist(HashMap<String, String> param) {
		return sqlSession.insert("CommonMapper.instagramMemberRegist", param);
	}

	@Override
	public UserDto instagramLogin(String idx) {
		return sqlSession.selectOne("CommonMapper.instagramLogin", idx);
	}

	@Override
	public List<PostDto> getEventPost() {
		return sqlSession.selectList("CommonMapper.getEventPost");
	}

	@Override
	public List<PostDto> loadRandomPost(int size) {
		return sqlSession.selectList("CommonMapper.loadRandomPost", size);
	}

	@Override
	public int feedbackBugSubmit(HashMap<String, String> param) {
		return sqlSession.insert("CommonMapper.feedbackBugSubmit", param);
	}

	@Override
	public int getSearchPostTotalCnt(String value) {
		return sqlSession.selectOne("CommonMapper.getSearchPostTotalCnt", value);
	}

	@Override
	public int getSearchTagTotalCnt(String value) {
		return sqlSession.selectOne("CommonMapper.getSearchTagTotalCnt", value);
	}

}
